/**
 * Created by FASHVN-001 on 2018/7/26.
 */
/**
 * Created by FASHVN-001 on 2018/6/25.
 */
/**
 * Created by xmsm on 2018/6/23.
 */
var newUrl = window.location.href;
//var newUrl = 'http://www.fashvn.com/xinwang/order.html?order=B419327415619723718763';//模拟参数

var newNumber0 = newUrl.split('?'); //参数
console.log(newNumber0);
var newNumber = newUrl.split('?')[1]; //参数
var newNumber2 = newNumber.split('='); //参数
console.log(newNumber2[0]);//order
console.log(newNumber2[1]);//B419327415619723718763

$('#dialogs').on('click', '.weui-dialog__btn', function(){
    $(this).parents('.js_dialog').fadeOut(200);
});
var $iosDialog0 =$('#iosDialog0');


$('#showIOSDialog1').on('click', function () {
    var userName = $.trim($(".user").val().toLowerCase()); //去掉字符串前后空格
    var passWord = $.trim($(".pw").val().toLowerCase());

    //判定用户名或密码是否为空
    if ($('.input_underline').val() == "")
    {
        $iosDialog0.fadeIn(100);
        $(".input_underline").eq(0).focus();
    }

    //核对信息
    checkLogin(userName ,passWord);
});
function checkLogin(user,pw){
    $.ajax({
        method: 'get',
        url: 'http://mc.fashvn.com/invoker',
        dataType: 'json',
        async: true,
        data:{
            'act':'l',
            'id':user,
            'pw':pw
        },// 用户名和密码
        success: function (result) {
            console.log(result);
            if (result.status == true) {
                localStorage.setItem("user", user);// 用户登录成功后将数据存放至localstorage
                localStorage.setItem("pw", pw);
                localStorage.setItem("token", result.token);
                localStorage.setItem("info", result.info);
                url = "./voucher.html?"+newNumber2[0]+"="+newNumber2[1];
                window.location.href = url; //成功跳转页面
            }else if(result.status == false){
                $iosDialog0.fadeIn(200).find('.message').html('用户名或密码错误');
            }

        }
    });
}